/* var Api = "http://songyujianiu.qicp.vip/"; */
var Api = "http://192.168.5.13:9000/";
new Vue({
  el: "#app",
  data: function () {
    return {
      list: null,
      userList: null,
      dialogUserList: false,
      userId: [],
      id: "",
      pageNum: 1,
      pageSize: 10,
      total: 0,
      sels: [],
    };
  },
  created: function () {
    this.List();
  },
  selsChange(sels) {
    this.sels = data 
  },
  methods: {
	  
    //  设置
    setUp: function (id) {
      let that = this;
      that.id = id;
      that.dialogUserList = true;
      var par = {
        pageNum: that.pageNum,
        pageSize: that.pageSize,
      };
      axios({
        method: "post",
        url: Api + "users/list",
        params: par,
      }).then(function (res) {
        if (res.data.code == "101") {
          that.userList = res.data.data.list;
          that.total = res.data.data.totalRow;
        }
        if (res.data.code == "102") {
          that.$message({
            type: "error",
            message: res.data.message,
          });
        }
      });
      /* const params = new URLSearchParams();
			params.append('loginName', '1');
			params.append('password', '12');
			axios.post('http://localhost:9000/', params)
				.then(function(response) {
					console.log(response.data)
					var code = response.data.code;
					if (code === '101'){

					}
					if (code === '102'){
						console.log(response.data.message)
					}
				})
				.catch(function(error) {
					console.log(error);
				}); */
    },
    // 保存
    preservation: function () {
      let that = this;
      const par = new URLSearchParams();
      par.append("fid", that.id);
      par.append("sonid", that.userId);
      axios({
        method: "post",
        url: Api + "equip/setsbson",
        params: par,
      }).then(function (res) {
        if (res.data.code == "101") {
          that.$message({
            type: "success",
            message: res.data.message,
          });
        } else {
          that.$message({
            type: "error",
            message: res.data.message,
          });
        }
      });
    },
    //  查看列表
    List() {
      let that = this;
      var par = {
        pageNum: that.pageNum,
        pageSize: that.pageSize,
      };
      axios({
        method: "post",
        url: Api + "users/list",
        params: par,
      }).then(function (res) {
        console.log(res);
        if (res.data.code == "101") {
          that.list = res.data.data.list;
          that.total = res.data.data.totalRow;
        }
        if (res.data.code == "102") {
          that.$message({
            type: "error",
            message: res.data.message,
          });
        }
      });
    },
	//跳转用户添加页面
    add() {
      window.location.href = "userAdd.html";
    },
	update(id){
		window.location.href = "userUpdate.html";
		window.localStorage.setItem("uid", id)
	},
    //  弹出框的全选
    handleSelectionChange(val) {
      console.log(val);
      var arr = [];
      let that = this;
      for (const item in val) {
        arr.push(val[item].userId);
      }
      that.userId = arr;
    },
	
    //  分页
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
  },
});
